ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Encryption/compression functions
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Encodes a character string or a buffer. To decode the result, simply use Decode.
Caution: As the result of encoding is a character string, it may vary from one project configuration to another, depending on the setting of string management at runtime.
Example
// Encodage d'une image en Base 64
Res is string = Encode(fLoadBuffer("MonImage.jpg"), encodeBASE64)
// Encodage d'une URL
Info(Encode("https://www.google.fr/?", encodeURLFromAnsi) + ...
	Encode(Encode("https://www.google.fr/?é", encodeURLFromAnsi), encodeURLParameter))
// Le buffer contient des caractères au format Unicode en iOS
// ou au format ANSI dans d'autres configurations (paramétrées en ANSI)
MessageEnBuffer is Buffer = fChargeBuffer(fDataDir()/"monbuffer.bin")
MessageEnBuffer = Encode(MessageEnBuffer, encodeBASE64NoCR)
// Conversion permettant d'avoir un buffer en ANSI et BASE 64 dans toutes les plateformes:
MessageEnBuffer = StringToUTF8(Encode(MessageEnBuffer, encodeBASE64NoCR))
Syntax
<Result> = Encode(<Data> [, <Encoding format>])
<Result>: Character string
Data encoded according to the selected format.
<Data>: Character string or Buffer
Data to encode.
<Encoding format>: Optional Integer constant
Format for encoding data:
encodeBASE64
(Default value)
BASE 64 format (complies with the RFC 4648 standard). Encoded text contains only printable characters and CRs (Carriage Returns).
PHP Carriage returns (CR) are removed.
encodeBASE64NoCRBASE 64 format (complies with RFC 4648 standard) without RCs (Carriage Returns). The encoded text contains printable characters only.
PHP This constant is not available.
encodeBASE64URLBASE 64 URL format (complies with the RFC 4648 standard). The encoded text contains printable characters only.
PHP This constant is not available.
encodeBASE85BASE 85 format. The encoded text contains printable characters only.
AndroidAndroid Widget Unsupported format.
PHP This constant is not available.
encodePCSASCII format. The encoded text contains printable characters only.
AndroidAndroid Widget Unsupported format.
encodeURLFromAnsiURL format. The encoded text only contains characters allowed in a URL. The text to encode is an ANSI string.
PHP This constant is not available.
encodeURLFromUnicodeURL format. The encoded text only contains characters allowed in a URL. The text to encode is a Unicode string.
PHP This constant is not available.
encodeURLFromUTF8URL format. The encoded text only contains characters allowed in a URL. The text to encode is a UTF-8 string.
PHP This constant is not available.
encodeURLParameterThis constant is used when it is necessary to pass a given URL (URL A) as a parameter to another URL (URL B). The reserved characters of URL A (//,?...) are encoded.
URL A (to be encoded) must be a valid URL. If it has parameters of its own, they must have been encoded with one of the following constants: encodeURLDfromAnsi, encodeURLDfromUnicode or encodeURLDfromUTF8.
PHP This constant is not available.
encodeUUEncodeUUEncode format. The encoded text contains printable characters only.
AndroidAndroid Widget Unsupported format.
Business / UI classification: Business Logic
Component: wd300std.dll
Minimum version required
  • Version 22
This page is also available for…
Comments
Exemplo com Fonte
https://repository.windev.com/resource.awp?file_id=281474976711928;exemplo-cryptografia-descryptografia
Boller
15 Mar. 2024
OBS
É muito importante fazer o encode e o decode base 64 quando usar em arquivos de texto ou arquivos ini, pois existe varios formatos de arquivos sendo eles: ansi, unicode, utf-8. E uma vez encodado e decodando a criptofrafia e descriptografia vai funcionar perfeitamente pois os caracteres originais estaram cifrados, se nao fazer o encode e decode os caracteres armazenados nao vao bater e a senha usada sera inutil e nao dara certo o procedimento.


Il est très important d'encoder et de décoder la base 64 lors de l'utilisation de fichiers texte ou de fichiers ini, car il existe plusieurs formats de fichiers : ansi, unicode, utf-8. Et une fois encodés et décodés, le cryptage et le décryptage fonctionneront parfaitement car les caractères originaux seront cryptés, si vous n'encodez pas et ne décodez pas les caractères stockés ne correspondront pas et le mot de passe utilisé sera inutile et la procédure ne fonctionnera pas.
Boller
15 Mar. 2024
Exemplo
E no Windev Mobile
//Criptografia
B_senha is Buffer = HashString(HA_HMAC_MD5_128, "bob-esponja")
B_resultado_Criptografado is Buffer = CryptStandard(buf_conteudo_sig, B_senha, cryptAES128)
B_resultado_Criptografado=encode(B_resultado_Criptografado, encodeBASE64)

info(B_resultado_Criptografado)


//Descriptografia
B_senha is Buffer = HashString(HA_HMAC_MD5_128, "bob-esponja")
B_resultado_Descriptografado is Buffer = decode(B_resultado_Criptografado, encodeBASE64)
B_resultado_Descriptografado = UnCryptStandard(B_resultado_Descriptografado, B_senha, cryptAES128)

info(B_resultado_Descriptografado )
Boller
15 Mar. 2024
Exemplo
//Exemplo para Criptografar
// se usar a criptografia em um arquivo texto ou ini deve fazer encode 64 bits.

sMessage is Buffer = "Message to encrypt"
bufKey is Buffer = HashString(HA_CKSUM_64, "password")
bufEncrypt is Buffer = CryptStandard(sMessage, bufKey, cryptDES)
bufEncrypt = encode(bufEncrypt, encodeBASE64)
Info(bufEncrypt)

// Exemplo para Decriptografar
bufKey is Buffer = HashString(HA_CKSUM_64, "password")
sResult is Buffer = decode(sResult, encodeBASE64)
sResult = UncryptStandard(bufEncrypt, bufKey, cryptDES)
Info(sResult)
Boller
15 Mar. 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 Mar. 2024
IMAGEN /STRING
//VOU MOSTRAR HOJE, COMO TRANSFORMAR
//UMA IMAGEN EM STRING E TRANSFORMAR
//UMA STRING EM UMA IMAGEM

IMG_IMAGEN_1 = "c:\ICONES\IC_OK_N.PNG" // VALIDADO
EDT_IMAGEN_TEXTO=Encode(fChargeBuffer(IMG_IMAGEN_1),encodeBASE64)
//--
IMG_IMAGEM_VOLTA = Decode(EDT_IMAGEN_TEXTO,encodeBASE64)

//BLOG COM VIDE E EXEMPLO

http://windevdesenvolvimento.blogspot.com/2017/08/aula-1237-windev-imagen-006-encodedecode.html

https://www.youtube.com/watch?v=KLr4-1wg_WQ


De matos
11 Aug. 2017

Last update: 09/24/2024

Send a report | Local help