29.11.2015, 14:58
(
Последний раз редактировалось AbyssMorgan; 25.12.2017 в 07:51.
Причина: Update v3.0.0
)
Hello, I would like to present include allowing encrypt file.
Return values:
Key types:
Max key length:
Example (ADMx32):
Pawn Code for File:
Screens:
http://i.imgur.com/UoIa31S.png
http://i.imgur.com/D2AoUeI.png
http://i.imgur.com/WUh3D37.png
Pawn Code for String:
Pawn Code for Dump File:
Pawn code for Split/Merge File:
Comments:
a) Max file size:
- 64 MB for SA:MP
- 16 EB for Windows application
b) File coding
- ASCII/ANSI (8 bit) for SA:MP
- Any for Windows application
Download:
ADM.inc
MD5.inc
ADM Console Applications
Dump File Open
Install:
Key Generator:
http://8.ct8.pl/admkg
Notice:
Posts can be made available in a other language forums, please remember to keep the author and permanent link to file on github and a link to post in forum samp.
Non-Registered Users:
Bug Report
PHP код:
/**********************************************************************************************************************************
* *
* )( ADM Encryption File )( *
* *
* Copyright © 2018 Abyss Morgan. All rights reserved. *
* *
* Download: https://github.com/AbyssMorgan/SA-MP/tre...nclude/SAM *
* Publication: https://sampforum.blast.hk/showthread.php?tid=595203 *
* Website: http://8.ct8.pl *
* *
* Plugins: SScanf *
* Modules: MD5 *
* *
* File Version: 3.0.0 *
* SA:MP Version: 0.3.7 *
* SScanf Version: 2.8.2 *
* *
* File Functions: *
* :InvertFile(const input[],const output[]); *
* :HexNegativeFile(const input[],const output[],key[]); *
* :RollXFile(const input[],const output[],key[]); *
* :ADMx32(const input[],const output[],key[]); *
* :ADMx64(const input[],const output[],key[]); *
* :ADMx128(const input[],const output[],key[]); *
* :ADMx256(const input[],const output[],key[]); *
* :ADMx512(const input[],const output[],password[],bool:invertpassword = false); *
* :MergeFile(const first_file[],const second_file[],bool:erase_second=false); *
* :MergeFileGroup(const group_name[],const output[],upperbound_index,bool:erase_input=false); *
* :SplitFile(const input[],const output[],max_size,&upperbound_index=0); *
* *
* String Functions: *
* :InvertString(input[],output[],maxdest = sizeof(output)); *
* :HexNegativeString(input[],output[],key[],maxdest = sizeof(output)); *
* :RollXString(input[],output[],key[],maxdest = sizeof(output)); *
* :ADMx32String(input[],output[],key[],maxdest = sizeof(output)); *
* :ADMx64String(input[],output[],key[],maxdest = sizeof(output)); *
* :ADMx128String(input[],output[],key[],maxdest = sizeof(output)); *
* :ADMx256String(input[],output[],key[],maxdest = sizeof(output)); *
* :ADMx512String(input[],output[],password[],bool:invertpassword = false,maxdest = sizeof(output)); *
* :StringToHexString(input[],output[],maxdest = sizeof(output)); *
* :HexStringToString(input[],output[],maxdest = sizeof(output)); *
* *
* Dump Functions: *
* :GetFreeID(); *
* :GetType(const name[]); *
* :IsOpen(index); *
* :IsValid(const name[]); *
* :Create(const name[],key[],type = KEY_TYPE_ADMx32); *
* :Destroy(index); *
* :Open(const name[],key[],type = KEY_TYPE_ADMx32); *
* :Close(index); *
* :Write(index,string[]); *
* :IsEmpty(const name[]); *
* *
* Extended Functions: *
* :Create(const name[]); *
* :IsValidKey(key[],type); *
* :GetKeyType(key[],bool:distorted = false); *
* :GetErrorName(code); *
* :DecodeADMKey(inputkey[],outputkey[],type,maxdest = sizeof(outputkey)); *
* :CreateADMKey(key[],type,maxdest = sizeof(key)); *
* *
* Return value: *
* ADM_ERROR_CODE_UNEXEC //Function unexecutable *
* ADM_ERROR_CODE_OK //Success *
* ADM_ERROR_CODE_INPUT //Input file not exist *
* ADM_ERROR_CODE_OUTPUT //Output file exist *
* ADM_ERROR_CODE_KEY //Invalid key *
* ADM_ERROR_CODE_SIZE //Invalid file size *
* ADM_ERROR_CODE_DEST //Destination size *
* ADM_ERROR_CODE_OPEN_INPUT //Open input file *
* ADM_ERROR_CODE_OPEN_OUTPUT //Open output file *
* ADM_ERROR_CODE_INVALID_TYPE //Invalid key type *
* ADM_ERROR_CODE_PASSWORD //Invalid password len *
* ADM_ERROR_CODE_MD5 //Invalid MD5 Load *
* ADM_ERROR_CODE_DMP_NAME //Invalid dump file name *
* ADM_ERROR_CODE_DMP_IDX //Invalid dump file index *
* *
* Key Generator: *
* http://8.ct8.pl/admkg *
* *
**********************************************************************************************************************************/
PHP код:
ADM_ERROR_CODE_UNEXEC //function unexecutable
ADM_ERROR_CODE_OK //success
ADM_ERROR_CODE_INPUT //input file not exist
ADM_ERROR_CODE_OUTPUT //output file exist
ADM_ERROR_CODE_KEY //invalid key
ADM_ERROR_CODE_SIZE //invalid file size
ADM_ERROR_CODE_DEST //error destination size
ADM_ERROR_CODE_OPEN_INPUT //error open input file
ADM_ERROR_CODE_OPEN_OUTPUT //error open output file
ADM_ERROR_CODE_INVALID_TYPE //invalid key type
ADM_ERROR_CODE_PASSWORD //invalid password length
ADM_ERROR_CODE_MD5 //invalid MD5 Load
ADM_ERROR_CODE_DMP_NAME //invalid dump file name
ADM_ERROR_CODE_DMP_IDX //invalid dump file index
PHP код:
KEY_TYPE_UNKNOWN //invalid key type
KEY_TYPE_HEXNEGATIVE
KEY_TYPE_ROLLX
KEY_TYPE_ADMx32
KEY_TYPE_ADMx64
KEY_TYPE_ADMx128
KEY_TYPE_ADMx256
PHP код:
MAX_KEY_LEN_HEXNEGATIVE
MAX_KEY_LEN_ROLLX
MAX_KEY_LEN_ADMx32
MAX_KEY_LEN_ADMx64
MAX_KEY_LEN_ADMx128
MAX_KEY_LEN_ADMx256
MAX_KEY_LEN_ADMx512
PHP код:
Encrypt Key: 191 12 239 86
Decrypt Key: 65 244 17 170
a - encrypt argument
b - decrypt argument
b = 256-a
256 - 191 = 65
256 - 12 = 244
256 - 239 = 17
256 - 86 = 170
PHP код:
new edi;
edi = ADM::ADMx32("test.txt","test.adm","191 12 239 86");
printf("ADM return code %d",edi);
switch(edi){
case ADM_ERROR_CODE_UNEXEC: print("Error: function unexecutable");
case ADM_ERROR_CODE_OK: {
print("Encryption successfully completed");
ADM::ADMx32("test.adm","test2.txt","65 244 17 170");
}
default: {
printf("%s",ADM::GetErrorName(edi));
}
}
http://i.imgur.com/UoIa31S.png
http://i.imgur.com/D2AoUeI.png
http://i.imgur.com/WUh3D37.png
Pawn Code for String:
PHP код:
new buffer[256];
ADM::ADMx32String("This is test string", buffer, "191 12 239 86");
printf("Binary data: '%s'",buffer); // 'tXЙЯubv3qbĘЯcČ(zV'
new buffer2[512]; //2 * sizeof(buffer)
ADM::StringToHexString(buffer,buffer2);
printf("Hex data: '%s'",buffer2); // '137458C9DF756276337162CADF7F63C8287A56'
PHP код:
#define SCRIPT_DUMP_KEY "191 12 239 86"
new GameModeLog = INVALID_DUMP_FILE,
GameModeLogName[80];
forward WriteGameModeError(string[]);
public WriteGameModeError(string[]){
if(!DMP::IsValid(GameModeLog)){
GameModeLog = DMP::Create(GameModeLogName,SCRIPT_DUMP_KEY,KEY_TYPE_ADMx32); //create new dump file
}
if(!DMP::IsOpen(GameModeLog)){
GameModeLog = DMP::Open(GameModeLogName,SCRIPT_DUMP_KEY,KEY_TYPE_ADMx32); //open dump file
}
new edi = DMP::Write(GameModeLog,string);
DMP::Write(GameModeLog,"\n");
if(edi == ADM_ERROR_CODE_OK) return 1;
printf("%s",ADM::GetErrorName(edi));
return 0;
}
public OnGameModeInit(){ //OnFilterScriptInit
new wl_date[3], wl_time[3];
getdate(wl_date[0],wl_date[1],wl_date[2]);
gettime(wl_time[0],wl_time[1],wl_time[2]);
format(GameModeLogName,sizeof(GameModeLogName),"GM_%02d.%02d.%02d_%02d%02d%02d.dmp",wl_date[0],wl_date[1],wl_date[2],wl_time[0],wl_time[1],wl_time[2]);
return 1;
}
public OnGameModeExit(){ //OnFilterScriptExit
if(DMP::IsEmpty(GameModeLogName)){
DMP::Close(GameModeLog);
fremove(GameModeLogName);
}
return 1;
}
PHP код:
new upperbound_index, edi;
edi = ADM::SplitFile("test.db","test_part",512,upperbound_index);
printf("[SplitFile] %d upp: %d",edi,upperbound_index);
edi = ADM::MergeFileGroup("test_part","new.db",upperbound_index);
printf("[MergeFileGroup] %d",edi);
a) Max file size:
- 64 MB for SA:MP
- 16 EB for Windows application
b) File coding
- ASCII/ANSI (8 bit) for SA:MP
- Any for Windows application
Download:
ADM.inc
MD5.inc
ADM Console Applications
Dump File Open
Install:
PHP код:
#include <MD5>
#include <SAM/ADM>
http://8.ct8.pl/admkg
Notice:
Posts can be made available in a other language forums, please remember to keep the author and permanent link to file on github and a link to post in forum samp.
Non-Registered Users:
Bug Report