hello everyone !
i am trying to crypt game assets 3d, sounds and texture .
is there any way to encrypt all assets and import into my game in pb?
how can i crypt game assets and load ?
- skinkairewalker
- Enthusiast
- Posts: 635
- Joined: Fri Dec 04, 2015 9:26 pm
Re: how can i crypt game assets and load ?
U could use the AES Cipher
Here is some code i wrote (Unicode):
Edit:
I dont know about the loading part.
Ogre is unable to load stuff from memory iirc.
Here is some code i wrote (Unicode):
Code: Select all
EnableExplicit
Procedure.i CryptBuffer(*Buffer,Length.i,Key.s,Decrypt.i = #False)
Protected *key
Protected *block
If Key And *Buffer And Length > 15
*key = Ascii(Key + Space(8))
If *key
*block = AllocateMemory(Length)
If *block
If Decrypt
If AESDecoder(*Buffer,*block,Length,*key,128,#Null,#PB_Cipher_ECB)
FreeMemory(*key)
ProcedureReturn *block
EndIf
Else
If AESEncoder(*Buffer,*block,Length,*key,128,#Null,#PB_Cipher_ECB)
FreeMemory(*key)
ProcedureReturn *block
EndIf
EndIf
FreeMemory(*block)
EndIf
FreeMemory(*key)
EndIf
EndIf
ProcedureReturn #Null
EndProcedure
Procedure.i Main()
Protected *encrypt
Protected *decrypt
Protected dummy.s
dummy = "Hello World!"
*encrypt = CryptBuffer(@dummy,StringByteLength(dummy) + 2,"Password")
If *encrypt
*decrypt = CryptBuffer(*encrypt,MemorySize(*encrypt),"Password",#True)
If *decrypt
ShowMemoryViewer(*decrypt ,MemorySize(*decrypt))
FreeMemory(*decrypt)
EndIf
FreeMemory(*encrypt)
EndIf
ProcedureReturn
EndProcedure
Main()
End
I dont know about the loading part.
Ogre is unable to load stuff from memory iirc.
- NicTheQuick
- Addict
- Posts: 1226
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: how can i crypt game assets and load ?
Why do you want to encrypt it? The key to decrypt the data would be in the app anyway.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Re: how can i crypt game assets and load ?
Well, for textures, as sam ple, you can just XOR randomize the image in memory.
For this you set RandomSeed() to a starting value and create as many randoms as you need.
Then you save it and load it the other way around.
Otherwise it is like Nick says.
The only way to get a handle this, is to dig very deep into the bag of tricks.
A Hint.
With AES you don't create a plain text password.
Also an Asccii password shortens the key with AES128 to 8 bytes.
But I think for a few textures or other this is little relevant.
For this you set RandomSeed() to a starting value and create as many randoms as you need.
Then you save it and load it the other way around.
Otherwise it is like Nick says.
The only way to get a handle this, is to dig very deep into the bag of tricks.
A Hint.
With AES you don't create a plain text password.
Also an Asccii password shortens the key with AES128 to 8 bytes.
But I think for a few textures or other this is little relevant.
地球上の平和
- NicTheQuick
- Addict
- Posts: 1226
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: how can i crypt game assets and load ?
Using a random seed is not encryption!Saki wrote:Well, for textures, as sam ple, you can just XOR randomize the image in memory.
For this you set RandomSeed() to a starting value and create as many randoms as you need.
Also randomizing the image's content and then saving it will result in a very bad image quality if you save it in a compressed format like JPG. That's because JPG is optimized for a reasonable image.Saki wrote:Then you save it and load it the other way around.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Re: how can i crypt game assets and load ?
Pre encrypted textures are never saved as JPEGs.
An encrypted or XOR-ed texture also successfully resists any compression.
A lossy compression destroys every encrypted image.
And if he puts the key in the code, he has no working encryption anyway.
Then he has no more than with the XOR, no matter how he does it.
Everything else you put in a structure, encrypt it using the address
of the first entry and sizeof and save it.
Included strings create as FixedString.
An encrypted or XOR-ed texture also successfully resists any compression.
A lossy compression destroys every encrypted image.
And if he puts the key in the code, he has no working encryption anyway.
Then he has no more than with the XOR, no matter how he does it.
Everything else you put in a structure, encrypt it using the address
of the first entry and sizeof and save it.
Included strings create as FixedString.
地球上の平和