Beispiel #1
0
 public static string DesencriptarTexto(byte[] texto, String nada)
 {
     int indice = texto.Length -1;
     while ((indice > 0) && (texto[indice] == 0x20))
         indice--;
     if (indice == 0)
         return String.Empty;
     Aleatorizador aleat = new Aleatorizador ();
     char[] res = new char [indice + 1];
     for (int i=0; i <= indice; i++){
         res[i] = (char) (texto[i] ^ aleat.GetNext());
     }
     return new String (res);
 }
Beispiel #2
0
        public static string DesencriptarTexto(byte[] texto, int off, int length)
        {
            length--;
            while ((length > 0) && (texto[off + length] == 0x20))
                length--;
            if (length == 0)
                return String.Empty;
            char[] res = new char [ length + 1 ];
            Aleatorizador aleat = new Aleatorizador();

            for (int i=0; i <= length; i++){
                res[i] = (char) (texto[off +i]  ^ aleat.GetNext());
            }
            return new String (res);
        }
Beispiel #3
0
        public static byte[] EncriptarTexto(string texto, int len)
        {
            byte[] ret = new byte[len];

            for (int i=0; i < len; i++){
                ret[i] = 0x20;
            }
            if ((texto == null) || (texto.Length == 0)){
                return ret;
            }
            if (texto.Length > len)
                texto = texto.Substring (0, len);

            Aleatorizador aleat = new Aleatorizador();

            int j=0;
            foreach (char c in texto){
                byte b = (byte) c;
                ret[j] = (byte) (b ^ aleat.GetNext());
                j++;
            }
            return ret;
        }