I am using the below code to encrypt and decrypt the data. Now I want to 
encrypt the data from Node JS and want to decrypt the data from Go lang. 
But I am not able to achieve it using GO lang.

var B64XorCipher = {
  encode: function(key, data) {
    return new Buffer(xorStrings(key, data),'utf8').toString('base64');
  },
  decode: function(key, data) {
    data = new Buffer(data,'base64').toString('utf8');
    return xorStrings(key, data);
  }};
function xorStrings(key,input){
  var output='';
  for(var i=0;i<input.length;i++){
    var c = input.charCodeAt(i);
    var k = key.charCodeAt(i%key.length);
    output += String.fromCharCode(c ^ k);
  }
  return output;}

>From go I am trying to decode like below I am not able to achieve it.

bytes, err := base64.StdEncoding.DecodeString(actualInput)
encryptedText := string(bytes)
fmt.Println(EncryptDecrypt(encryptedText, "XXXXXX"))

func EncryptDecrypt(input, key string) (output string) {
    for i := range input {
        output += string(input[i] ^ key[i%len(key)])
    }

    return output}

Can someone help me to resolve it.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to