I got bored in my IT Class one day and wrote this up. Figured I'd share. The only thing I can think of to add is the, if a letter is capitalized, it returns capitalized. Other then that, numbers work too!
Forgot! The isNumeric Function.PHP Code:
public static String Offset(String toEncrypt, Int32 offsetValue)
{
String alphabet = "abcdefghijklmnopqrstuvwxyz";
String newEncryption = String.Empty;
foreach (Char character in toEncrypt)
{
if (isNumeric(character.ToString()) == false)
{
Int32 curPosition = 0;
for (int i = 0; i < alphabet.Length; i++)
{
if (alphabet[i] == character)
{
curPosition = i;
break;
}
}
Int32 newPosition = curPosition + offsetValue;
if (newPosition >= alphabet.Length)
newPosition = (curPosition + offsetValue) - alphabet.Length;
newEncryption += alphabet[newPosition];
}
else
{
newEncryption += Int32.Parse(character.ToString()) + offsetValue;
}
}
return newEncryption;
}
PHP Code:
public static Boolean isNumeric(String Value)
{
double num;
bool isNum = double.TryParse(Value, out num);
return true != false ? isNum : true;
}
Results 1 to 8 of 8
Thread: [C#] Offset Encryption
- 07 Oct. 2012 08:00pm #1
[C#] Offset Encryption
- 08 Oct. 2012 02:58am #2
Hey, it's you. Although the final line of your isNumeric function is lulsy. Seeing as how true is never going to equal false, you're obviously always going to return isNum, so why didn't you just use:
Code:public static Boolean isNumeric(String Value) { double num; return double.TryParse(Value, out num); }
- 08 Oct. 2012 03:56am #3
Artificial - decomposing bad code since 2005.
Edit: Looks like someone doesn't know how to use ternary operators properly, lol.
http://forum.logicalgamers.com/sourc...-negative.html
Nice contribution though, OP. Stay active more.Last edited by The Unintelligible; 08 Oct. 2012 at 04:05am.
- 08 Oct. 2012 04:05am #4
Either way, it still worked. Thanks Arti.
As for activity, I'm currently bridging internet from my friends laptop. I haven't had internet in roughly 4 months.
- 08 Oct. 2012 02:49pm #5
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 607.00
Oh man, what happened? Just no money to pay for internet bills?
Protip: Start wardriving to find open networks around you, and then learn about cracking WEP, WPA, and WPA2 so you can just have internet wherever you are. It's surprising how many open or insecure networks there are all around you.
- 08 Oct. 2012 04:00pm #6
- 09 Oct. 2012 12:09am #7
Also, illegal.
- 09 Oct. 2012 02:19am #8