pvpgn-twilight 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changes +6 -1
- data/examples/pvpgn_test.rb +3 -1
- data/ext/pvpgn.c +28 -24
- data/pvpgn-twilight.gemspec +2 -1
- metadata +2 -2
data/Changes
CHANGED
data/examples/pvpgn_test.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
require 'rubygems'
|
1
2
|
require 'pvpgn'
|
2
3
|
#puts 'PVPGN Gem Version:' + PVPGN::Version
|
3
4
|
puts 'the following will hash to 2e0236a3649381fe99cdce4b5b59adffa3167c7b:'
|
4
5
|
puts 'hello -> ' + PVPGN::BNHash('hello') #will hash to: 2e0236a3649381fe99cdce4b5b59adffa3167c7b
|
5
|
-
puts 'HELLO -> ' + PVPGN::BNHash('HELLO') #will hash to: 2e0236a3649381fe99cdce4b5b59adffa3167c7b
|
6
|
+
puts 'HELLO -> ' + PVPGN::BNHash('HELLO') #will hash to: 2e0236a3649381fe99cdce4b5b59adffa3167c7b
|
7
|
+
puts 'HeLlO -> ' + PVPGN::BNHash('HeLlO') #will hash to: 2e0236a3649381fe99cdce4b5b59adffa3167c7b
|
data/ext/pvpgn.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#define PVPGN_TWILIGHT_VERSION "0.2.
|
1
|
+
#define PVPGN_TWILIGHT_VERSION "0.2.5"
|
2
2
|
#define PVPGN_TWILIGHT_MODULE "PVPGN"
|
3
3
|
#define __TEST__ 0
|
4
4
|
/**************************************************/
|
@@ -20,9 +20,10 @@
|
|
20
20
|
//#include "d2bitstream.h"
|
21
21
|
//#include "twilight.h"
|
22
22
|
#include "ruby.h"
|
23
|
+
#include <stdio.h>
|
23
24
|
#endif
|
24
25
|
|
25
|
-
//bit rotation macros, instead of the MSVC _rotl and _rotr instrisics(
|
26
|
+
//bit rotation macros, instead of the MSVC _rotl and _rotr instrisics(taken from pvpgn)
|
26
27
|
#define ROTL(x,n,w) (((x) << ((n) & (w - 1))) | ((x) >> (((-(n)) & (w - 1)))))
|
27
28
|
#define ROTL32(x,n) ROTL(x,n,32)
|
28
29
|
#define ROTL16(x,n) ROTL(x,n,16)
|
@@ -251,7 +252,7 @@ static void UTILITY_ToLower(char* pString)
|
|
251
252
|
|
252
253
|
while((nChar = *pString))
|
253
254
|
{
|
254
|
-
*pString++ = ((nChar < 'A' || nChar > 'Z') ? nChar : (nChar +
|
255
|
+
*pString++ = ((nChar < 'A' || nChar > 'Z') ? nChar : (nChar + ' '));
|
255
256
|
}
|
256
257
|
}
|
257
258
|
|
@@ -288,10 +289,9 @@ static void UTILITY_HexToText(char* pBuffer, unsigned int dwHex, unsigned int bU
|
|
288
289
|
}
|
289
290
|
}
|
290
291
|
|
291
|
-
static char* PVPGN_CreateHash(char* pHash, signed int nSize, char pHashOut
|
292
|
+
static char* PVPGN_CreateHash(char* pHash, signed int nSize, char* pHashOut)
|
292
293
|
{
|
293
294
|
unsigned long dwLength;
|
294
|
-
unsigned long i;
|
295
295
|
unsigned char* pData = (unsigned char*)pHash;
|
296
296
|
unsigned long dwHash[5] = {0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0};
|
297
297
|
unsigned long dwTemp[80];
|
@@ -301,7 +301,6 @@ static char* PVPGN_CreateHash(char* pHash, signed int nSize, char pHashOut[41])
|
|
301
301
|
return 0;
|
302
302
|
}
|
303
303
|
|
304
|
-
pHashOut[40] = 0;
|
305
304
|
UTILITY_ToLower(pHash);
|
306
305
|
while(nSize > 0)
|
307
306
|
{
|
@@ -312,12 +311,17 @@ static char* PVPGN_CreateHash(char* pHash, signed int nSize, char pHashOut[41])
|
|
312
311
|
pData += dwLength;
|
313
312
|
}
|
314
313
|
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
314
|
+
pHashOut[40] = 0;
|
315
|
+
/*
|
316
|
+
UTILITY_HexToText(&pHashOut[0],dwHash[0],0);
|
317
|
+
UTILITY_HexToText(&pHashOut[8],dwHash[1],0);
|
318
|
+
UTILITY_HexToText(&pHashOut[16],dwHash[2],0);
|
319
|
+
UTILITY_HexToText(&pHashOut[24],dwHash[3],0);
|
320
|
+
UTILITY_HexToText(&pHashOut[32],dwHash[4],0);
|
321
|
+
*/
|
322
|
+
|
323
|
+
sprintf(pHashOut,"%x%x%x%x%x",dwHash[0],dwHash[1],dwHash[2],dwHash[3],dwHash[4]);
|
324
|
+
return pHashOut;
|
321
325
|
}
|
322
326
|
|
323
327
|
#if ( __TEST__ )
|
@@ -329,7 +333,7 @@ static char* PVPGN_CreateHash(char* pHash, signed int nSize, char pHashOut[41])
|
|
329
333
|
int main(int argc, char *argv[])
|
330
334
|
{
|
331
335
|
char szInput[24];
|
332
|
-
char szHashOut[
|
336
|
+
char szHashOut[64];
|
333
337
|
printf("Please Enter Password: ");
|
334
338
|
scanf("Please Enter Password: %s",szInput);
|
335
339
|
printf("Hash: %s\n",PVPGN_CreateHash(szInput,strlen(szInput),szHashOut));
|
@@ -351,20 +355,20 @@ int main(int argc, char *argv[])
|
|
351
355
|
* converted to a lower case string, the input is also automatically
|
352
356
|
* converted to lower case
|
353
357
|
*/
|
354
|
-
static VALUE RUBY_BNHash(
|
358
|
+
static VALUE RUBY_BNHash(VALUE vPass)
|
355
359
|
{
|
356
|
-
char szHashOut[
|
357
|
-
VALUE vPassword;
|
360
|
+
static char szHashOut[64];
|
358
361
|
char* szPass;
|
362
|
+
int nSize;
|
359
363
|
|
360
|
-
|
364
|
+
szPass = StringValuePtr(vPass);
|
365
|
+
if((nSize = strlen(szPass)) < 1)
|
361
366
|
{
|
362
|
-
rb_raise(rb_eRuntimeError,"RUBY_BNHash(): Invalid
|
363
|
-
}
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
return rb_str_new2(PVPGN_CreateHash(szPass,strlen(szPass),szHashOut));
|
367
|
+
rb_raise(rb_eRuntimeError,"RUBY_BNHash(): Invalid Password Size");
|
368
|
+
}
|
369
|
+
|
370
|
+
PVPGN_CreateHash(szPass,nSize,szHashOut);
|
371
|
+
return rb_str_new2(szHashOut);
|
368
372
|
}
|
369
373
|
|
370
374
|
void Init_pvpgn()
|
@@ -373,6 +377,6 @@ void Init_pvpgn()
|
|
373
377
|
|
374
378
|
RUBY_Module = rb_define_module(PVPGN_TWILIGHT_MODULE);
|
375
379
|
RUBY_RegisterVariable(Version,rb_str_new2(PVPGN_TWILIGHT_VERSION));
|
376
|
-
|
380
|
+
RUBY_RegisterFuncEx(BNHash,1);
|
377
381
|
}
|
378
382
|
#endif
|
data/pvpgn-twilight.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{pvpgn-twilight}
|
3
|
-
s.version = "0.2.
|
3
|
+
s.version = "0.2.5"
|
4
4
|
s.date = %q{2010-02-04}
|
5
5
|
s.authors = ["Lorenzo 'Necrolis' Boccetti"]
|
6
6
|
s.email = %q{necrolis@gamil.com}
|
@@ -10,5 +10,6 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.files = ["pvpgn-twilight.gemspec","ext/pvpgn.c","examples/pvpgn_test.rb","ext/extconf.rb","Changes","docs/pvpgn-twilight.txt","pvpgn-twilight.gemspec"]
|
11
11
|
s.extensions << 'ext/extconf.rb'
|
12
12
|
s.has_rdoc = true
|
13
|
+
s.rubyforge_project = 'see gemcutter.org'
|
13
14
|
s.extra_rdoc_files = ["Changes","ext/pvpgn.c","docs/pvpgn-twilight.txt"]
|
14
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pvpgn-twilight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lorenzo 'Necrolis' Boccetti
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version:
|
54
54
|
requirements: []
|
55
55
|
|
56
|
-
rubyforge_project:
|
56
|
+
rubyforge_project: see gemcutter.org
|
57
57
|
rubygems_version: 1.3.5
|
58
58
|
signing_key:
|
59
59
|
specification_version: 3
|