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

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -