Quantcast
Channel: Zer's Programming Page
Viewing all 119 articles
Browse latest View live

CryptSharp (.NET Library)

$
0
0

Just wanted to give you a total shout man. I have been reading all day today and yesterday. I am a total .Net noob writing a specific server-app and was looking for a way to secure the passwords as much as possible even for a noob. Did an awesome job with this library allowing me to write my server in vb .net....

Was wondering one thing...

Dim cryptedPassword As String
        cryptedPassword = CryptSharp.Utility.SCrypt.ComputeDerivedKey("password", "s4lt", 262144, 8, 1, Nullable, 20)


Why will that not work?


Please Come Back

$
0
0

PLEASE, The games today don't have the gameplay Faldon had.

HidSharp

$
0
0

I have noticed a slight inconsistency in the behaviour of HidSharp on Windows VS Mac OSX...

Essentially, I have a Full Speed HID device which on Windows reports input and output report sizes of 65 bytes, and OSX reports 64 bytes for both.

I have been able to get the device to work on OSX by omitting the first byte on the output report, and by padding the input report with a 0 byte. ( the first byte is always 0 with this device...)

I am quite new to USB Hid, and I have read some documentation which states that the maximum input/output report size for a full speed device is 64 bytes, could this be the reason this is occurring? And if so, why would Windows allow 65 byte report size? Or is there a different reason for what I am seeing here?

Thanks
-Jared

Bug in Second Language

$
0
0

I found a bug in the Second Language library version 1.0.0 also available via NuGet.

The bug is in SecondLanguage\SpecialFormatters.cs at the bottom of the file:

        /// <summary>
        /// Applies C printf style formatting, using a specific format provider.
        /// </summary>
        /// <param name="provider">The format provider to use, or <c>null</c> for the system default.</param>
        /// <param name="format">The format string.</param>
        /// <param name="args">Arguments to replace the format string's placeholders with.</param>
        /// <returns>The formatted translated string.</returns>
        public static string CustomC(IFormatProvider provider, string format, params object[] args)
        {
            Throw.If.Null(format, "format").Null(args, "args");

            int i = 0;
            Func<object> getArg = () =>
                {
                    object arg = i >= 0 && i < args.Length ? args[i] : null;
                    i++; return arg;
                };
            return CPrintfRegex.Replace(format, match =>
            {
                string parameter = match.Groups["parameter"].Value,
                    flags = match.Groups["flags"].Value,
                    widthString = match.Groups["width"].Value,
                    precisionString = match.Groups["precision"].Value,
                    length = match.Groups["length"].Value,
                    type = match.Groups["type"].Value;

                if (match.Value == "%%") { return "%"; }

                if (parameter != "") { i = int.Parse(parameter) - 1; }

                int width = 0;
                if (widthString != "") { width = widthString == "*" ? getArg() as int? ?? 0 : int.Parse(widthString); }

                int? precision = null;
                if (precisionString != "") { precision = precisionString == "*" ? getArg() as int? : int.Parse(precisionString); }

                object value = getArg() ?? "";
                string s = value.ToString() ?? "";

                if ("xX".Contains(type) && value is IFormattable)
                {
                    s = ((IFormattable)value).ToString(type, provider);
                }

                if (precision < 0) { precision = 0; }
                if ("fFeEgG".Contains(type) && value is IFormattable)
                {
                    s = ((IFormattable)value).ToString(type + precision.ToString(), provider);
                }
                else if (s.Length > precision)
                {
                    s = s.Substring(0, (int)precision);
                }

                int padCount = Math.Abs(width) - s.Length;
                var padChar = flags.Contains("0") ? '0' : ' ';
                if (padCount > 0)
                {
                    bool left = flags.Contains("-") ^ (width < 0);
                    var padding = new string(padChar, padCount);
                    if (left) { s += padding; } else { s = padding + s; }
                }

                i++; return s;
            });
        }
 

The above is the original code. The

i++;

before

return s;

has to be removed.

If you don't remove it, simple tests like the following won't work:

            Assert.AreEqual("100 200", printf("%s %s", 100, 200));

HIDSharp on Raspberry

$
0
0

I've got Stamps.com scale (Vendor ID 0x1446, Product ID 0x6A73) and in Windows HIDSharp reads the scale's byte stream fine (minor change in Test project => loader.GetDevices(0x1446, 0x6A73).First() ).

However, when running the same source on Mono (Debian Linux on a Raspberry Pi), the scale is not found.

Do you have any suggestions on how I can resolve this and get the scale recognized?

Many thanks in advance,
Clay Ver Valen

Bug in SecondLanguage reading .mo files?

$
0
0

First of all, thank you for developing the SecondLanguage library. We have been using it successfully for a few months now, for the internationalization of a relatively large application, with almost 3000 text entries in .po files.

I've been looking at a switch to .mo files for fasting application startup, and I ran into failing unit tests when attempting to fetch pluralized forms with a context variable, E.g.:

  Translation.GetPluralString("Box","Boxes", 1, "Noun");

This returns null for my test case.  If I switch the unit test to read from the corresponding .po file, all is well.

I'm building the .mo file using  the GNU msgfmt, with the defaults:  msgfmt  message.po -omessages.mo

BTW, it took a bit of a sales pitch to move the team from the .NET resx approach to using gettext tools, but we've been very happy with the switch.

LinuxHidStream GetFeature/SetFeature

$
0
0

Hi,

I was looking to use your library to control a Blink(1) device.

It works fine in windows but on a raspberry pi (the real target device) it won't work because GetFeature & SetFeature are not implemented.

Can you please tell me if this is something that is being looked at or if you can provide some pointers as to how I might add the functionality.

Thanks,
Barry.

START A NEW SERVER FOR FRESH START xD.

$
0
0

START A NEW SERVER FOR FRESH START xD.


START A NEW SERVER FOR FRESH START xD.

$
0
0

START A NEW SERVER FOR FRESH START xD.

Faldon - Faldon is an online RPG I wrote. The game has some flaws, but

$
0
0

Faldon - Faldon is an online RPG I wrote. The game has some flaws, but I encourage you to try it.
only flaw is your lack of attention!!

HidSharp - Catch error when device is unplugged

$
0
0

I'm using the lib in windows.

I'm continuously watching the HidStream for data which means that at each callback from BeginRead() I start a new BeginRead().

That is the way that I found to continuously watch for new inputs.

The only problem is that when the device is disconnected from the USB port, there is an error that I can't handle.
This error is saved in Exception field of AsyncResult<T> but there are 2 problems there:

1. - The callback parameter is IAsyncResult, which doesn't have Exception field.
2. - The Exception field in AsyncResult<T> is not public, so I cannot access it anyway.

I managed to solve by making the field Exception Public and inside the callback handler I do a cast to AsyncResult<T> which I also made public.

Is that right? Is there any better way to do that?

Thanks in advance.

20th January 2016.

$
0
0

After the server crashed few days ago, stat reset dosnt work anymore. Can you please fix that?
Also, Mr spy broke the spell Mind blast few years ago by accident, any way to fix that by any chance?

Cheers.

Updated ENet for C#?

$
0
0

I'm curious if ENet for C# is going to be updated to the latest ENet version.

Also, is there a repository for the code online somewhere?

HidSharp stream.Write throws an exception

$
0
0

Just started using HidSharp, and love the elegant simplicity of finding devices.

I can succesfully find my device, Open it and attach it to a HidStream
If I do Read's on it as in the demo programs, they timeout as expected because my device will not return any data until it has recd a command.

So when I try to send it a command using stream.Write  it always ends up with thisException:
  An unhandled exception of type 'System.IO.IOException' occurred in HidSharp.dll
  Additional information: Operation failed early.

Its simple enough that I cannot see what I am doing wrong.  Running on Windows10 and VS2013.  I can duplicate the behavior from HidSharp.Test in CS.  And also from my own app in CPP using HidSharp.dll as a reference.

After the stream is open I do
                    var bytesout = System.Text.Encoding.ASCII.GetBytes("CFGR0");
                    stream.Write(bytesout);

More detail below...
Would appreciate any help figuring this out.
Thanks
Daraius


If I break in the debugger it ends up in
<NativeMethods.cs>
        public unsafe static void OverlappedOperation(IntPtr ioHandle,
            IntPtr eventHandle, int eventTimeout, IntPtr closeEventHandle,
            bool overlapResult,
            NativeOverlapped* overlapped, out uint bytesTransferred)
        {
            bool closed = false;

            if (!overlapResult)
            {
                int win32Error = Marshal.GetLastWin32Error();
                if (win32Error != NativeMethods.ERROR_IO_PENDING)
                {
                    throw new IOException("Operation failed early.", new Win32Exception());
                }

                IntPtr* handles = stackalloc IntPtr[2];

Multi HID Devices on USB HID Sharp

$
0
0

Hi
Win7  32

Does HIDsharp allow me to have the following report, prefably xls,  Have 2 or more USB RFID readers, all identical.  No serial numbers or vid pid.  Only thing different is the hub/port number.  One line for each reader.

hub/port #
Last data string transmitted from USB  (about 14 character tag number)  max of 2 reads per second
timestamp

As each string comes in it will be sent off to Excel for processing by location , and the next reading is put there (or overwritten).

A model railway project to track rolling stock.

Thanks and regards

Charles Harris
New Zealand


Rescale RemoteViewing result...

$
0
0

Hi Zer,

RemoteViewing is a really good work! Thanks for it!

I have to resize the display (source=1920x1080, target=480x270) in client side (Source ) for making a grid containing several remote screens... Is it possible? How to do that?

Thanks in advance for your answer.

damien/dipisoft.

HidSharp VB6 examples problem

$
0
0

Hello!
I try vb6 example from Version 1.1 (July 28, 2012) (includes C# and VB6 samples) on Win XP 32,
and receive 2 errors (look at attached screen shots), tlb file is present in References.
Can I get working example or advise please?

savepic.su/7179465.jpg
savepic.su/7182537.jpg

Crypter.CheckPassword

$
0
0

Hello,

Congratulations on the excellent CryptSharp Library. It's simply brilliant.
Now I am a script kiddie at max and I have a certain query.

I recently used this usage in one of my codes (to check if a word matches with the hash):

Crypter.CheckPassword(someWord, "$apr1$***********");

Now my understanding is that Apche APR MD5 uses a timeseed to generate random hashes, how do you still manage to match them using this library?
I will be really thankful for an explanation.

HIDSharp - adding event

$
0
0

Dear All,
I am kind of newbie in programming, thus I want to ask you (advanced programmers) if there is any way (and if it is please point it out) to add an event which can be fired by this library when new data is available on particular USB device (maybe via DeviceLoader class).
For example: my hardware is sending data only when I press a button, and I do not want to directly pool for the button status on the PC application constantly.
I would like to have OnNewUSBDataAvailable event to which I can attach functions.

Is it possible to archive this ? and if yes, then how should this be implemneted? Guidance will be really appreciated.

Many thanks in advance and best regards,
Grzegorz

Bug in Second Language

$
0
0

I found a bug in the Second Language library version 1.0.0 also available via NuGet.

The bug is in SecondLanguage\SpecialFormatters.cs at the bottom of the file:

        /// <summary>
        /// Applies C printf style formatting, using a specific format provider.
        /// </summary>
        /// <param name="provider">The format provider to use, or <c>null</c> for the system default.</param>
        /// <param name="format">The format string.</param>
        /// <param name="args">Arguments to replace the format string's placeholders with.</param>
        /// <returns>The formatted translated string.</returns>
        public static string CustomC(IFormatProvider provider, string format, params object[] args)
        {
            Throw.If.Null(format, "format").Null(args, "args");

            int i = 0;
            Func<object> getArg = () =>
                {
                    object arg = i >= 0 && i < args.Length ? args[i] : null;
                    i++; return arg;
                };
            return CPrintfRegex.Replace(format, match =>
            {
                string parameter = match.Groups["parameter"].Value,
                    flags = match.Groups["flags"].Value,
                    widthString = match.Groups["width"].Value,
                    precisionString = match.Groups["precision"].Value,
                    length = match.Groups["length"].Value,
                    type = match.Groups["type"].Value;

                if (match.Value == "%%") { return "%"; }

                if (parameter != "") { i = int.Parse(parameter) - 1; }

                int width = 0;
                if (widthString != "") { width = widthString == "*" ? getArg() as int? ?? 0 : int.Parse(widthString); }

                int? precision = null;
                if (precisionString != "") { precision = precisionString == "*" ? getArg() as int? : int.Parse(precisionString); }

                object value = getArg() ?? "";
                string s = value.ToString() ?? "";

                if ("xX".Contains(type) && value is IFormattable)
                {
                    s = ((IFormattable)value).ToString(type, provider);
                }

                if (precision < 0) { precision = 0; }
                if ("fFeEgG".Contains(type) && value is IFormattable)
                {
                    s = ((IFormattable)value).ToString(type + precision.ToString(), provider);
                }
                else if (s.Length > precision)
                {
                    s = s.Substring(0, (int)precision);
                }

                int padCount = Math.Abs(width) - s.Length;
                var padChar = flags.Contains("0") ? '0' : ' ';
                if (padCount > 0)
                {
                    bool left = flags.Contains("-") ^ (width < 0);
                    var padding = new string(padChar, padCount);
                    if (left) { s += padding; } else { s = padding + s; }
                }

                i++; return s;
            });
        }
 

The above is the original code. The

i++;

before

return s;

has to be removed.

If you don't remove it, simple tests like the following won't work:

            Assert.AreEqual("100 200", printf("%s %s", 100, 200));
Viewing all 119 articles
Browse latest View live