Search Results

Search found 4650 results on 186 pages for 'perfect hash'.

Page 42/186 | < Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >

  • C# Extend array type to overload operators

    - by Episodex
    I'd like to create my own class extending array of ints. Is that possible? What I need is array of ints that can be added by "+" operator to another array (each element added to each), and compared by "==", so it could (hopefully) be used as a key in dictionary. The thing is I don't want to implement whole IList interface to my new class, but only add those two operators to existing array class. I'm trying to do something like this: class MyArray : Array<int> But it's not working that way obviously ;). Sorry if I'm unclear but I'm searching solution for hours now... UPDATE: I tried something like this: class Zmienne : IEquatable<Zmienne> { public int[] x; public Zmienne(int ilosc) { x = new int[ilosc]; } public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return false; } return base.Equals((Zmienne)obj); } public bool Equals(Zmienne drugie) { if (x.Length != drugie.x.Length) return false; else { for (int i = 0; i < x.Length; i++) { if (x[i] != drugie.x[i]) return false; } } return true; } public override int GetHashCode() { int hash = x[0].GetHashCode(); for (int i = 1; i < x.Length; i++) hash = hash ^ x[i].GetHashCode(); return hash; } } Then use it like this: Zmienne tab1 = new Zmienne(2); Zmienne tab2 = new Zmienne(2); tab1.x[0] = 1; tab1.x[1] = 1; tab2.x[0] = 1; tab2.x[1] = 1; if (tab1 == tab2) Console.WriteLine("Works!"); And no effect. I'm not good with interfaces and overriding methods unfortunately :(. As for reason I'm trying to do it. I have some equations like: x1 + x2 = 0.45 x1 + x4 = 0.2 x2 + x4 = 0.11 There are a lot more of them, and I need to for example add first equation to second and search all others to find out if there is any that matches the combination of x'es resulting in that adding. Maybe I'm going in totally wrong direction?

    Read the article

  • How to add values dynamically to I18n?

    - by Dima Goltsman
    I have many ymls in my rails app, and i want to put some of them in other service, so that i can call this from multiple places. the response of this call will be a hash. {"en" : {"test" : {"text1" : "hi english"}, {"text2" : "mambo number %{num}"} }, "es" : {"test" : {"text1" : "hi espaniol"}, {"text2" : "mamboes numeros %{num}"} } } is there a way i can load that hash into I18n translations like I18n.add_translations(some_hash) so i can access them with I18n.t("test.text1") I18n.t("test.text2", :num => 5) how can i achieve it?

    Read the article

  • how to save byte[] value to varbinary(64) field on database

    - by shamim
    byte[] a = HashEncript("a"); public byte[] HashEncript(string Password) { SHA512Managed sha = new SHA512Managed(); byte[] hash = sha.ComputeHash(UnicodeEncoding.Unicode.GetBytes(Password)); return hash; } i want to save byte[] a this value on my database .My database field is varbinary(64).i use msSQL2008 .how to save ,want to know the insert query with C# code.

    Read the article

  • generate sha256 with openssl and C++

    - by Stanislav Palatnik
    Hello, I'm looking to create a hash with sha256 using openssl and C++. I know there's a similar post about this here: http://stackoverflow.com/questions/918676/generate-sha-hash-in-openssl, but I'm looking to specifically create sha256. UPDATE: Seems to be a problem witht he include paths. It can't find any openssl functions even though I included #include "openssl/sha.h" and I included the paths in my build -I/opt/ssl/include/ -L/opt/ssl/lib/ -lcrypto

    Read the article

  • How to save byte[] to varbinary(64) field in database

    - by shamim
    I have byte[] a = HashEncrypt("a"); with public byte[] HashEncrypt(string password) { SHA512Managed sha = new SHA512Managed(); byte[] hash = sha.ComputeHash(UnicodeEncoding.Unicode.GetBytes(password)); return hash; } I want to save byte[] a to my database. My database field is a varbinary(64). I'm using SQL Server 2008. I want to know the insert query with C# code. I am using ADO.NET

    Read the article

  • compare password hashes between c# and coldfusion

    - by czuroski
    Hello, I have a password hash that is stored in a table and is put there by the following coldfusion script- #Hash(EnCrypt(UCase(GetPass.username),EnCode))# I am trying to add some outside functionality within a c# application. I would like to be able to take advantage of the data that already exists so that I can authenticate users. Does anyone know how I can replicate the above coldfusion code in c#? Thanks for any thoughts.

    Read the article

  • Refactor a link and an image

    - by Mihail Stoynov
    I have to write an link with an image inside. Instead of explaining, here's the code I have now: <c:if test="${userSession.loggedUser eq null and company.image != null}"> <a onclick="${rich:component('loginPanel')}.show()"> <img src="/download.do?hash=#{company.image.hash}" /> </a> </c:if> <c:if test="${userSession.loggedUser eq null and company.image == null}"> <a onclick="${rich:component('loginPanel')}.show()"> <img src="${request.contextPath}/img/icons/logo_default.jpg" /> </a> </c:if> <c:if test="${userSession.loggedUser ne null and company.image != null}"> <a href="company.xhtml?${company.name}"> <img src="/download.do?hash=#{company.image.hash}" /> </a> </c:if> <c:if test="#{userSession.loggedUser ne null and company.image == null}"> <a href="company.xhtml?${company.name}"> <img src="${request.contextPath}/img/icons/logo_default.jpg" /> </a> </c:if> This code looks awful - there are two exact links with two exact images but combined in all possible combinations. Is there a better way? Is there a way to avoid c:if - it created tables? Update: Bozho proposes: You can replace <c:if and <a with <h:outputLink rendered="#{..}". Apart from that I don't see any other optimization. But it doesn't work. This does not render correctly: <a href=> <h:outputLink rendered="#{..} <h:outputLink rendered="#{..} </a> (the image is outside the anchor) This does render fine: <h:outputLink value=> <h:outputLink rendered="#{..} <h:outputLink rendered="#{..} </a> , but it always adds href and in two of the cases I don't want href when rendered.

    Read the article

  • What's wrong with this statement in perl?

    - by benjamin button
    print "$_", join(',',sort keys %$h),"\n"; It's giving me an error below: Use of uninitialized value in string at missing_months.pl line 36. 1,10,11,12 this print statement is present in a for loop as below: foreach my $num ( sort keys %hash ) { my $h = $hash{$num}; print "$_", join(',',sort keys %$h),"\n"; }

    Read the article

  • Store request.headers in a serialized model attribute

    - by Horace Loeb
    Here's my model: class Comment < ActiveRecord::Base serialize :request_headers end But when I try to do @comment.request_headers = request.headers I get a TypeError (can't dump anonymous class Class) exception. Another way to ask my question: how can I convert request.headers into a Hash? It uses a Hash under the covers so this should be easy, no?

    Read the article

  • Why is this statement treated as a string instead of its result?

    - by reve_etrange
    I am trying to perform some composition-based filtering on a large collection of strings (protein sequences). I wrote a group of three subroutines in order to take care of it, but I'm running into trouble in two ways - one minor, one major. The minor trouble is that when I use List::MoreUtils 'pairwise' I get warnings about using $a and $b only once and them being uninitialized. But I believe I'm calling this method properly (based on CPAN's entry for it and some examples from the web). The major trouble is an error "Can't use string ("17/32") as HASH ref while "strict refs" in use..." It seems like this can only happen if the foreach loop in &comp is giving the hash values as a string instead of evaluating the division operation. I'm sure I've made a rookie mistake, but can't find the answer on the web. The first time I even looked at perl code was last Wednesday... use List::Util; use List::MoreUtils; my @alphabet = ( 'A', 'R', 'N', 'D', 'C', 'Q', 'E', 'G', 'H', 'I', 'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W', 'Y', 'V' ); my $gapchr = '-'; # Takes a sequence and returns letter = occurrence count pairs as hash. sub getcounts { my %counts = (); foreach my $chr (@alphabet) { $counts{$chr} = ( $[0] =~ tr/$chr/$chr/ ); } $counts{'gap'} = ( $[0] =~ tr/$gapchr/$gapchr/ ); return %counts; } # Takes a sequence and returns letter = fractional composition pairs as a hash. sub comp { my %comp = getcounts( $[0] ); foreach my $chr (@alphabet) { $comp{$chr} = $comp{$chr} / ( length( $[0] ) - $comp{'gap'} ); } return %comp; } # Takes two sequences and returns a measure of the composition difference between them, as a scalar. # Originally all on one line but it was unreadable. sub dcomp { my @dcomp = pairwise { $a - $b } @{ values( %{ comp( $[0] ) } ) }, @{ values( %{ comp( $[1] ) } ) }; @dcomp = apply { $_ ** 2 } @dcomp; my $dcomp = sqrt( sum( 0, @dcomp ) ) / 20; return $dcomp; } Much appreciation for any answers or advice!

    Read the article

  • Simulating MySql OLD_PASSWORD in .NET or MS SQL ?

    - by miensol
    I have started a new project in .NET which uses some old system's datababase in MySql. The data stored in mysql is periodicaly transfered to MS Sql on which our system works. I need to authenticate users with their login and password. User's passwords are stored as hash generated by OLD_PASSWORD function from mysql. Is there any way to generate such hash using Ms Sql or .NET ?

    Read the article

  • extendible hashing

    - by Phenom
    I need to make a program that shows the hash value of a given key, using extendible hashing. In extendible hashing, I know that the buckets split and directories change. So if I make my program, do I have to already know things like if the bucket it hashes to is filled, or do I not have to worry about those things and just compute a hash value based on the key?

    Read the article

  • Extend multiple classes at once

    - by Starkers
    I want to share a method amongst all Ruby's data object classes. That is to say the following classes: Hash String Number Array Firstly, any classes I've missed out? Secondly, how can I share my_method amongst all classes at once? class Hash def my_method "hi" end end class String def my_method "hi" end end class Number def my_method "hi" end end class Array def my_method "hi" end end

    Read the article

  • making a password-only auth with bcrypt and mongoose

    - by user3081123
    I want to create service that let you login only with password. You type a password and if this password exists - you are logged in and if it's not - username is generated and password is encrypted. I'm having some misunderstandings and hope someone would help me to show where I'm mistaken. I guess, it would look somewhat like this in agularjs First we receive a password in login controller. $scope.signup = function() { var user = { password: $scope.password, }; $http.post('/auth/signup', user); }; Send it via http.post and get in in our node server file. We are provided with a compare password bcrypt function userSchema.methods.comparePassword = function(candidatePassword, cb) { bcrypt.compare(candidatePassword, this.password, function(err, isMatch) { if (err) return cb(err); cb(null, isMatch); }); }; So right now we are creating function to catch our http request app.post('/auth/signup', function(req, res, next) { Inside we use a compair password function to realize if such password exists or not yet. So we have to encrypt a password with bcrypt to make a comparison First we hash it same way as in .pre var encPass; bcrypt.genSalt(10, function(err, salt) { if (err) return next(err); bcrypt.hash(req.body.password, salt, function(err, hash) { if (err) return next(err); encPass=hash; )}; )}; We have encrypted password stored in encPass so now we follow to finding a user in database with this password User.findOne({ password: encPass }, function(err, user) { if (user) { //user exists, it means we should pass an ID of this user to a controller to display it in a view. I don't know how. res.send({user.name}) //like this? How should controller receive this? With $http.post? } else { and now if user doesn't exist - we should create it with user ID generated by my function var nUser = new User({ name: generId(), password: req.body.password }); nUser.save(function(err) { if (err) return next(err); )}; )}; )}; Am I doing anything right? I'm pretty new to js and angular. If so - how do I throw a username back at controller? If someone is interested - this service exists for 100+ symbol passphrases so possibility of entering same passphrase as someone else is miserable. And yeah, If someone logged in under 123 password - the other guy will log in as same user if he entered 123 password, but hey, you are warned to make a big passphrase. So I'm confident about the idea and I only need a help with understanding and realization.

    Read the article

  • Are parametrized calls/sanitization/escaping characters necessary for hashed password fields in SQL queries?

    - by Computerish
    When writing a login system for a website, it is standard to use some combination of parameterized calls, sanitizing the user input, and/or escaping special characters to prevent SQL injection attacks. Any good login system, however, should also hash (and possibly salt) every password before it goes into an SQL query, so is it still necessary to worry about SQL injection attacks in passwords? Doesn't a hash completely eliminate any possibility of an SQL injection attack on its own?

    Read the article

  • mcrypt_encrypt fails to initialise

    - by mixkat
    I am trying to encrypt some data in PHP using the Rijndael cipher in CBC mode with a 256bit key but for some reason I get the following error message: mcrypt_encrypt() Module initialization failed My code: $hashKey = hash('sha256',$key); $iv = hash('sha256',$hashKey); // ------Cipher-------------key-------------Data-------------Mode---------IV-- $encryptedQuestion = base64_encode(mcrypt_encrypt('MCRYPT_RIJNDAEL_256', $hashKey , $_POST['question'], MCRYPT_MODE_CBC, $iv)); Can anyone see whats wrong with this?

    Read the article

  • Check directory for files, retrieve first file

    - by Lowgain
    I'm writing a small ruby daemon that I am hoping will do the following: Check if a specific directory has files (in this case, .yml files) If so, take the first file (numerically sorted preferrably), and parse into a hash Do a 'yield', with this hash as the argument What I have right now is like: loop do get_next_in_queue { |s| THINGS } end def get_next_in_queue queue_dir = Dir[File.dirname(__FILE__)+'/../queue'] info = YAML::load_file(queue_dir[0]) #not sure if this works or not yield info end I'd like to make the yield conditional if possible, so it only happens if a file is actually found. Thanks!

    Read the article

  • Open SSL without SHA1

    - by Hellnar
    Is there any way to use Open SSL without any SHA1 hash functions and using one of SHA2 functions instead of it? I think firstly, I should find all the functions that call SHA1 algorithm, and I should understand why SHA1 is still used. While changing the hash function, the bits are different in SHA1 and SHA2 so it may cause some problems. It confuses me...

    Read the article

  • If I never ever use HashSet, should I still implement GetHashCode?

    - by Dimitri C.
    I never need to store objects in a hash table. The reason is twofold: coming up with a good hash function is difficult and error prone. an AVL tree is almost always fast enough, and it merely requires a strict order predicate, which is much easier to implement. The Equals() operation on the other hand is a very frequently used function. Therefore I wonder whether it is necessary to implement GetHashCode (which I never need) when implementing the Equals function (which I often need)?

    Read the article

  • PHP user sessions

    - by Temek
    I'm bit confused. I've been building my sites with my own session system, but i'm not sure how secure the php's own session system is. My session system usually just has user id and quite harsh hash, which does not include user name or password for generation. I save the hash in the user database and as a cookie to confirm the user session on every page load. So my question is should i keep using my own systems or try out php sessions?

    Read the article

< Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >