static void LIL_EncodeDecode(Args _args)
{
#File
Set permissionSet;
InteropPermission interopPerm;
FileIOPermission fileIOPerm;
boolean fileExists;
str path,
base64Encode,
base64ext;
bindata bindata;
int pos;
container data;
permissionSet = new Set(Types::Class);
path = @"C:\Images\test.png";
fileIOPerm = new FileIOPermission(path,#io_read);
permissionSet.add(fileIOPerm);
interopPerm = new InteropPermission(InteropKind::ClrInterop);
permissionSet.add(interopPerm);
CodeAccessPermission::assertMultiple(permissionSet);
fileExists = System.IO.File::Exists(path);
if(fileExists)
{
bindata = new bindata();
bindata.loadFile(path);
base64Encode = bindata.base64Encode();
}
info(base64Encode);//stringa codificata
//decodifica...
if(base64Encode)
{
pos = strFind(base64Encode, ';', 1, 60);
if(pos)
{
base64ext = subStr(base64Encode, 1, pos-1);
}
pos = strFind(base64Encode, ',', 1, 60);
base64Encode = strDel(base64Encode, 1, pos);
bindata = new bindata();
data = BinData::loadFromBase64(base64Encode);
bindata.setData(data);
bindata.saveFile(@"C:\Images\test2.png");
}
info("Terminato!");
}
martedì 2 ottobre 2018
AX 2012 - Codifica/Decodifica base64 di un file
Con questo job possiamo codificare / decodificare un file in Base64:
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento