Last active
October 8, 2016 05:23
-
-
Save jiangzhuo/030f2a636f3499eef51b0a8382ca3382 to your computer and use it in GitHub Desktop.
rijndael
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var edge = require('edge'); | |
var decrypt = edge.func(function() {/* | |
using System; | |
using System.IO; | |
using System.Threading.Tasks; | |
using System.Security.Cryptography; | |
using System.Text; | |
public class Startup | |
{ | |
public async Task<object> Invoke(object input) | |
{ | |
return Helper.Decrypt((String)input); | |
} | |
} | |
static class Helper | |
{ | |
public static String Decrypt(String text) | |
{ | |
MemoryStream memoryStream = new MemoryStream(); | |
RijndaelManaged rijndaelManaged = new RijndaelManaged(); | |
byte[] array = Convert.FromBase64String(text); | |
byte[] rgbKey = Convert.FromBase64String("WrgCpjnHvtgPiVz+/iqAfPIQ7BEuI6J8aNi22IHfwes="); | |
byte[] rgbIV = Convert.FromBase64String("1+JNzb8MHok3sNwT8xGDjg=="); | |
CryptoStream cryptoStream = new CryptoStream(memoryStream, rijndaelManaged.CreateDecryptor(rgbKey, rgbIV), CryptoStreamMode.Write); | |
cryptoStream.Write(array, 0, array.Length); | |
cryptoStream.Close(); | |
memoryStream.Close(); | |
Console.WriteLine("解密后:"); | |
Console.WriteLine(Encoding.UTF8.GetString(memoryStream.ToArray())); | |
Console.WriteLine(); | |
return memoryStream.ToString(); | |
} | |
} | |
*/}); | |
decrypt("b+kBzbgNXJsPqticgR8YpibQcPXNNvCBy5I5INpat2Y=",function function_name() { | |
console.log(arguments) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mcrypt = require('mcrypt'); | |
var alog="rijndael-128"; | |
var mode="cbc"; | |
var mc = new mcrypt.MCrypt(alog, mode); | |
var plaintext = 'Here is some data to encrypt!'; | |
var key = '2whKTzmnFv58oMkETBpoveTiXMwi8lywcVdYERmuBv8='; | |
var ciphertext = 'TxxETBHynGNYmNXuvi14gNZTBi1si+nzrHc2oV6ENYw='; | |
var iv = 'cvlMwu4BcaQzQZdUqBL7YQ=='; | |
mc.open(new Buffer(key, 'base64'), new Buffer(iv, 'base64')); | |
var a = mc.decrypt(new Buffer(ciphertext, 'base64')); | |
console.log(alog, mode, mc.getIvSize(), a.toString('utf8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment