Skip to content
This repository was archived by the owner on Jun 10, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions C#_Cert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public LockSolver()
TestCaseDictionary = JsonSerializer.Deserialize<Dictionary<string, string>>(Base64DecodedString);
}

public void Run(Func<string, string> function)
public void run(Func<string, string> function)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid: Methods should be PascalCase under the C# Naming Convention.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method *names

{
Function = function;
var sampleTest = Function("12345");
Expand All @@ -94,7 +94,7 @@ public void Run(Func<string, string> function)
}
}

public string GetPassword(string userID)
public string getPassword(string userID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid: Method names should be PascalCase under the C# Naming Convention.

{
string answer = String.Join("", TestAnswers) +
Function(CheckType(typeof(string), userID).ToString());
Expand All @@ -115,10 +115,10 @@ static string HexStringFromBytes(byte[] bytes)
}
}

public static long Encrypt(long number) =>
public static long encrypt(long number) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid: Method names should be PascalCase under the C# Naming Convention

Convert.ToInt64(CheckType(typeof(long), number)) >> 23 ^ 2333;

static string Solve(string token)
static string solve(string token)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid: Method names should be PascalCase under the C# Naming Convention.

{
// Complete this method.
// REMEMBER! You need C# 8.0 to have this script running without errors.
Expand Down
29 changes: 16 additions & 13 deletions JS_Cert.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ if (typeof atob === 'undefined' || !atob){
var testCases = new Map();

var userAns = [];
var userFunc = null;

function encrypt(num) {
if (typeof(num) != 'number')
throw 'encrypt: The given argument is not a number';
return (num >> 23) ^ 2333;
}

const getHash=function(M,N=!1,T=1337){var D,z,O=void 0===T?2166136261:T;for(D=0,z=M.length;D<z;D++)O^=M.charCodeAt(D),O+=(O<<1)+(O<<4)+(O<<7)+(O<<8)+(O<<24);
return N?("0000000"+(O>>>0).toString(16)).substr(-8):O>>>0},getTestCases=()=>{var M=atob("MDMwMzE1MTM0MTMwOS00NjAwNy8xMjEzNDk4NTMxMDM0NTAzMTQvNDM0MTM0ODk"+
Expand All @@ -20,19 +25,23 @@ const getHash=function(M,N=!1,T=1337){var D,z,O=void 0===T?2166136261:T;for(D=0,
"zc2MTQvMTY3NjE2ODcyNC8yMjg2MDcyOTQ5LzkyMzgwMjc1OS80MjU3OTM5OTQ3LzQyOTE0OTUxODU=").split("/");
if(M.length!=N.length)throw"Error: Cannot load testcase datasets.";for(var T=0;T<M.length;)testCases.set(M[T],N[T]),T++};

function run(func) {
var LockSolver = function() {
this.userFunc = null;
}

LockSolver.prototype.run = function(func) {
var sampleAns = func('12345');
if(typeof(sampleAns) != "string")
throw 'run: Return value of given function is not type of string'
if (sampleAns != '2353')
throw 'run: Failed to pass sample testcase. Your answer is: ' + sampleAns + ' instead of 2353';

getTestCases();
userFunc = func;
this.userFunc = func;
i = 1;
for (let [key, value] of testCases.entries()) {
let testCase = key, ansHash = value;
result = userFunc(testCase);
result = this.userFunc(testCase);
if (ansHash != null && getHash(result) != ansHash && i < 6)
throw 'run: Failed to open lock #' + i + ', your solution is probably wrong.';

Expand All @@ -41,19 +50,13 @@ function run(func) {
}
}

function getPassword(userID) {
LockSolver.prototype.getPassword = function(userID) {
if (typeof(userID) != 'string')
throw 'getPassword: The given argument is not of type string';
answer = userAns.join('') + userFunc(userID);
answer = userAns.join('') + this.userFunc(userID);
return getHash(answer);
}

function encrypt(num) {
if (typeof(num) != 'number')
throw 'encrypt: The given argument is not a number';
return (num >> 23) ^ 2333;
}

function solve(token) {
// complete this function
}
}