AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de cifrado/compresión
  • Encrypting and decrypting an external file
  • Encryption in Android/Java and decryption by a WINDEV application (or conversely)
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Advertencia
A partir de la versión 24, Crypt se conserva por motivos de compatibilidad. Esta función ha sido reemplazada por Encrypt.
Encrypts a character string in binary format or in ASCII format.
Remarks:
  • This character string can be decrypted by Decrypt.
  • If the encryption and the decryption are performed on different platforms (encryption in Android and decryption in Windows for example), use EncryptStandard and DecryptStandard. For more details, refer to the "Remarks" paragraph.
Ejemplo
// Encrypt a string
Res = Encrypt("My credit card number is 52327453829011", "Password")
// Encode a string in base 64
bufBase64 is Buffer = Encrypt(bufToEncode, "", compressNone + cryptNone, encodeBASE64)
Sintaxis
<Result> = Encrypt(<String to encrypt> , <Password> [, <Type of encryption> [, <Format of encrypted string>]])
<Result>: Character string
  • Encrypted character string,
  • Empty string ("") if an error occurred. To get more details on the error, use ErrorInfo.
<String to encrypt>: Character string
Text to encrypt.
<Password>: Character string
Password used to encrypt the character string. This password will be used to decrypt the encrypted string (Decrypt). A long password optimizes the encryption security.
<Type of encryption>: Optional constant (or combination of constants)
Indicates the type of encryption and/or compression:
  • Type of encryption:
    cryptAnsiThe encryption is identical to the one performed in a WINDEV or WEBDEV application. Useful for the applications that encrypt in WINDEV Mobile and that decrypt in WINDEV for example.
    To use this constant, <Format of encrypted string> must correspond to the encodePCS constant.
    Note: If the constant crypteAnsi is not combined with another constant specifying the type of encryption, the <Password> parameter is ignored.
    This constant can only be used in WINDEV Mobile for Windows CE.
    AndroidWidget Android iPhone/iPad This constant has no effect.
    cryptFast
    (Default value)
    Priority is given to the encryption speed (algorithm on 128 bits).
    AndroidWidget Android This constant is not available.
    cryptNoneNo encryption is performed
    cryptRC516Priority is given to the encryption security (RC5 algorithm on 16 rounds).
    AndroidWidget Android This constant has no effect.
    cryptSecurePriority is given to the encryption security (RC5 algorithm on 128 bits).
    AndroidWidget Android The algorithm used will be a PBE algorithm (Password Based Encryption).
  • Type of compression:
    compressLZWThe string will be compressed before it is encrypted.
    AndroidWidget Android This constant has no effect.
    compressNone
    (Default value)
    No compression is performed.
    AndroidWidget Android This constant has no effect.
    compressShortStringThe string will be compressed via an algorithm optimized for the short character strings. This compression will be effective only if the cryptNone constant is selected and if <Format of encrypted string> corresponds to the encodeNone constant.
    AndroidWidget Android This constant has no effect.
<Format of encrypted string>: Optional Integer constant
Indicates the format of encrypted string:
encodeBASE64BASE 64 format. The file is encrypted with the BASE64 algorithm. The encrypted file will be larger (about 30%) than the initial file.
To perform an encoding in base 64, you also have the ability to use Encode associated with the encodeBASE64 or encodeBASE64URL constant.
The base64 format can be used to insert an encrypted file into the email body for example.
encodeNoneBinary format. The encrypted file may contain non-printable characters. The file will be larger (about 4 bytes) than the initial file.
encodePCS
(Default value)
ASCII format. The encrypted file will contain printable characters only. The encrypted file will be larger (about 30%) than the initial file.
This format can be used to insert an encrypted file into the email body for example.
encodeUUEncodeUUEncode format. The file is encrypted with the UUEncode algorithm. The encrypted file will be larger (about 30%) than the initial file.
This format can be used to insert an encrypted file into the email body for example.
AndroidWidget Android This parameter is ignored. The encrypted string will be in BASE 64 format.
Observaciones

Encrypting and decrypting an external file

To encrypt/decrypt an external file, use fEncrypt and fDecrypt.
Android

Encryption in Android/Java and decryption by a WINDEV application (or conversely)

Warning: the encryption/decryption algorithms used in Java and Android are not the same as those used by WINDEV. Therefore, you cannot encrypt a character string in Java or Android and decrypt it with WINDEV and vice versa.
To encrypt a character string in Java or Android and to decrypt it with WINDEV (or conversely), use EncryptStandard and DecryptStandard.
Componente: wd300std.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
exemplo com fonte
https://repository.windev.com/resource.awp?file_id=281474976711928;exemplo-cryptografia-descryptografia
Boller
15 03 2024
LINK Exemplos
https://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/4235-comandos-criptografia-descriptografia-para-usar-windev-webdev-windev/read.awp
Boller
15 03 2024
Example Encripta
//https://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/2251-about-cryptstandart-and-uncryptstandart-2254/read.awp

Encripta(St is string, Pw is string)
x is string
i is int
n is int
p is int
j is int
//n0 is int
ok is boolean

p = 0

FOR i = 1 TO Length(St)
p += 1
IF p > Length(Pw) THEN p = 1
j = Asc(Middle(Pw, p, 1)) OR 128
n = Asc(Middle(St, i))

ok = False

WHILE ok = False
n = BinaryXOR(n, j) //encripta...
IF n < 31 THEN //se char de controle
n = (128 + n) //somar 128 e
//GoTo DeNovo //ecripta novamente
ELSE IF n > 127 AND n < 159 THEN //se nesta faixa pode ser char de controle
n = n - 128 //tira 128 e
//GoTo DeNovo //encripta novamente
ELSE
ok = True
END
END
x = x + Charact(n) //concatena string encriptada


END

RESULT x
BOLLER
05 04 2017

Última modificación: 28/03/2025

Señalar un error o enviar una sugerencia | Ayuda local