Re: minisphere 1.2.4
Reply #602 –
Works perfectly:
function game(){
var originaltext = "Hello Sphere Worlds!";
var source = CreateByteArrayFromString( originaltext );
var compressed = DeflateByteArray( source , 9); // Sphere Syntax
//var compressed = source.deflate(9); // MiniSphere Syntax
if( compressed !== null ){
var inflated = InflateByteArray(compressed, 1024*16); // Sphere Syntax
//var inflated = compressed.inflate(); // MiniSphere Syntax
if(inflated !== null){
var copy = CreateStringFromByteArray(inflated);
if(copy === originaltext)
Abort( "SUCCES:" + CreateStringFromByteArray(inflated) );
else
Abort("ByteArray to string failed");
}else{
Abort( "Decompression failed." );
}
}else{
Abort("Compression failed.")
}
}
// MiniSphere to Sphere syntax
function DeflateByteArray(BA_obj,ratio){
return BA_obj.deflate(ratio);
}
function InflateByteArray(BA_obj,size){
return BA_obj.inflate(size); // need size or we can make a inflate bomb?
}
edit: A deflate bomb is possible: http://security.stackexchange.com/questions/51071/zlib-deflate-decompression-bomb