How to Convert Javascript Code to C# Code -
I have a JavaScript method I wrote on C # but it does not work.
Javascript code
var __AM = 65521; Function CC (A) {var C = 1, B = 0, D, E; (E = 0; e & lt; a.length; e ++) {d = a.charCodeAt (e); C = (C + D)% __AM; B = (B + C)% __AM; } Return b
My written C # code
Private string CC (string A) {var __AM = 65521; Int e; Long d; Long C = 1, B = 0; (E = 0; e & lt; a.Length; e ++) {var p = encoding.unicode.getbits (A [E]. Ostring ()); D = Convert. ToInt32 (P. First ()); C = (C + D)% __AM; B = (B + C)% __AM; } Return b.ToString () + c.ToString (); }
JS Test
cc ("4JipHEz53sU1406413803");
Result: 1132332429
C # Exam
CC ("4JipHEz53sU1406413803");
Result: 172781421
How can I get JS value in C #?
This code works:
Private string cc (string A) {var __AM = 65521; Int e; Long d; Long C = 1, B = 0; (E = 0; e & lt; a.Length; e ++) {d = (int) a [E]; C = (C + D)% __AM; B = (B + C)% __AM; } Return (b & lt; & lt; 16 | c). Ostring (); }
Comments
Post a Comment