2016-10-04 22:49:08

Hello,
I think that this is a mistake in the engine, but writing here because I can possibly do some wrong or if not then autor of engine can repair this mistake.
I have the following code:
sound zvuk;
file reader;
string sounddata;

void main() {
reader.open("die.ogg","rb");
sounddata=reader.read();
reader.close();
set_sound_decryption_key("this is an example key",true);
zvuk.load_from_memory(sounddata);
zvuk.play_wait();
zvuk.close();
}

When I launch this code, sound die.ogg should to play, but nothing. If I use normal load function, all is good. If I try to play some unencrypted sound, It works too, only sounds with encryption have this kind of problem.
Is there some way to load sound from memory to apply decryption? Or should I to use string_decrypt function?
Thanks.

2016-10-05 00:06:28

I imagine load_from_memory ignores encryption. I don't know if you'd want to use string_decrypt or file_decrypt to get around this.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2016-10-05 11:04:30

Hello,
citation from bgt's manual, concrete from part about function load_from_memory of object sound:
"Remarks:
The data must be a valid Ogg Vorbis or Wave stream, with or without encryption. If the data is encrypted, the engine will decrypt it automatically using the global sound decryption key."

I want to use some like:
zvuk.load_from_memory(string_decrypt(sounddata,"encryption key"));
but now I found that this does not work, too if I try to save file from decrypted string sounddata, wlc can not play It. So I think, if function file_encrypt and string_decrypt uses the same encrypting algorithm.

2016-10-05 17:35:37

Hey Rasťa! :-)
I think the important difference here is that the string and file encryption/decryption functions treat the file differently.

In which format do you have the actual sound file saved? Was it encrypted using file_encrypt or string_encrypt? Or are you saying that you have tried both ways and none of them worked?
If none worked at all with load_from_memory, then yes, this might be a bug in BGT itself.

The important thing is that you should almost never use the text mode when creating files with BGT. I can't remember the reason the text mode was even added in the first place but when I discussed this with Philip ages ago, he told me to always use the binary mode when possible. This is especially important if you save a file which contains string_encrypted data. If it's saved in text mode or attempted to be decrypted with file_decrypt rather than string_decrypt, it's just not going to work.

Lukas

I won't be using this account any more or participating in the forum activity through other childish means like creating an alternate account. I've asked for the account to be removed but I'm not sure if that's actually technically possible here. Just writing this for people to know that I won't be replying, posting new topics or checking private messages until the account is potentially removed.

2016-10-06 12:52:22

Hello,

I don’t know if you can load a sound from a file object, the only reason you would want to do that is to grab it from a pack for something, but not even then do I usually do something like that.

What you do is this. Declare the decryption key, either in the declaration itself, or store the key in a string, then set the key to the string.

You then either set sound path, path to pack file, or if your baking it into the final executable, use a star sign to denote an internal pack name, set_sound_storage left parenthesis * right parenthesis. This denotes your using a pack file that you baked into the executable, refer to the manual on packaging files with your executable.

Now, when you go to load, you just load a sound as normal, unless your loading from a pack, at which point you have to remember what your internal naming scheme is for the sound files inside the pack.
If you use something like x pack, the process is simplified a bit, because you can refer to sound files as you would for the source version of the game.
I hope this helps and isn’t too short, I’m writing this up before my folks and I try to escape a hurricane.

2016-10-06 13:47:55

Wow, Omar, hope you're all right. It takes quite a gut to respond to a post on a forum before leaving the site of a coming huricane. yikes)

Basically, you are right but what Rastislav is asking about is how the load_from_memory method of the sound object works together with encryption. This method was added to the class in one of the last few most recent BGT updates.

Lukas

I won't be using this account any more or participating in the forum activity through other childish means like creating an alternate account. I've asked for the account to be removed but I'm not sure if that's actually technically possible here. Just writing this for people to know that I won't be replying, posting new topics or checking private messages until the account is potentially removed.

2016-10-10 11:00:48

Hello,
hmm, important, the sound that I am trying to load is in ogg format, encrypted by file_encrypt function. I thougth, that only difference between file_encrypt and string_encrypt functions is, that file_encrypt takes as a parameter input file name and output file name, is useful to save space for programmer who dont must declare a readers and writers with this function. I thougth also that file_encrypt function uses string_encrypt to work, because string is always storing binary data, too in case if loaded as a text, only some different interpretation from program can be detected but the data are still binary. I am using binary load and write always too, because did not see huge difference between this two methods. But I will try to encrypt original sound by string_encrypt function and next load, normal by setting global encryption key which should work for encrypted files as in load function but not, and manually decryption too ofcourse by using string_decrypt by myself.

2016-10-10 13:11:12

Yeah, try both and let us know the results. It would certainly be useful to have this tested thoroughly. If none work, or if it only works by manually reading the file and decrypting the data as a string first, then there is probably really a bug in load_from_memory.

Lukas

I won't be using this account any more or participating in the forum activity through other childish means like creating an alternate account. I've asked for the account to be removed but I'm not sure if that's actually technically possible here. Just writing this for people to know that I won't be replying, posting new topics or checking private messages until the account is potentially removed.

2016-10-12 09:48:52

hello,
so, I tryed both and found this results:
If is file encrypted by function string_encrypt, function load_from_memory can not load it. If I used string_decrypt function, all was gód and sound is played, but if I used set_sound_decryption_key and not remove manually decryption function, sound played too what is wrong, because there should be a double decription with logical wrong result. So from this I think, that function load_from_memory is completely ignoring decryption ability declared in It's reference.

I am also smally disturbed by difference between file_encrypt and string_encrypt functions, because both takes binary and returns binary forms, but give different results. I will test It in some different programming language with aes 256 bit support, but I think now, that there is some difference in algorithm of this two functions.

2016-10-12 14:19:43

Yeah, this definitely looks like load_from_memory completely ignores the decryption key set with set_sound_decryption_key, you're right.

I'd be curious to know the differences between string and file encryption in BGT myself.

Lukas

I won't be using this account any more or participating in the forum activity through other childish means like creating an alternate account. I've asked for the account to be removed but I'm not sure if that's actually technically possible here. Just writing this for people to know that I won't be replying, posting new topics or checking private messages until the account is potentially removed.

2016-10-12 20:12:13

hi,
I also just tried this just now after looking this over some more and came to the same conclusion.
I dunno, maybe it's some kind of safety feature? Or maybe, it is indeed broken.
I would post my code but every time I post code here the forum does weird things with it.