ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Encryption/compression functions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Encodes a character string or a buffer. To decode the result, simply use Decode.
Example
// Encode an image in Base64
Res is string = Encode(fLoadBuffer("MyImage.jpg"), encodeBASE64)
// Encode a URL
Info(Encode("https://www.google.fr/?", encodeURLFromAnsi) + ...
Encode(Encode("https://www.google.fr/?é", encodeURLFromAnsi), encodeURLParameter))
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).
encodeBASE64NoCRBASE 64 format (complies with RFC 4648 standard) without RCs (Carriage Returns). The encoded text contains printable characters only.
encodeBASE64URLBASE 64 URL format (complies with the RFC 4648 standard). The encoded text contains printable characters only.
encodeBASE85BASE 85 format. The encoded text contains printable characters only.
encodePCSASCII format. The encoded text contains printable characters only.
encodeURLFromAnsiURL format. The encoded text only contains characters allowed in a URL. The text to encode is an ANSI string.
encodeURLFromUnicodeURL format. The encoded text only contains characters allowed in a URL. The text to encode is a Unicode string.
encodeURLFromUTF8URL format. The encoded text only contains characters allowed in a URL. The text to encode is a UTF-8 string.
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 its own parameters, they must have been encoded with one of the following constants: encodeURLFromAnsi, encodeURLFromUnicode or encodeURLFromUTF8.
encodeUUEncodeUUEncode format. The encoded text contains printable characters only.
Business / UI classification: Business Logic
Component: wd290std.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: 05/02/2023

Send a report | Local help