EzDevInfo.com

key interview questions

Top key frequently asked interview questions

How do you test a public/private DSA keypair?

Is there an easy way to verify that a given private key matches a given public key? I have a few *.pub, and a few *.key files, and I need to check which go with which.

Again, these are pub/key files, DSA.

I would really prefer a one-liner of some sort...


Source: (StackOverflow)

How do I find out which keystore was used to sign an app?

I have an app which is signed and several keystore files. I'd like to update the app, so I need to find out which one of keys was used.

How can I match which keystore was used to originally sign my app against various keystores I have on my machine?


Source: (StackOverflow)

Advertisements

Get HTML5 localStorage keys

I'm just wondering how to get all key values in localStorage.


I have tried to retrieve the values with a simple JavaScript loop

for (var i=1; i <= localStorage.length; i++)  {
   alert(localStorage.getItem(i))
}

But it works only if the keys are progressive numbers, starting at 1.


How do I get all the keys, in order to display all available data?


Source: (StackOverflow)

Characters allowed in php array keys?

I have some php array keys that are populated with a lot of weird characters.

Is this allowed? Are there any constraints to what I cannot use?


Source: (StackOverflow)

Is the primary key automatically indexed in MySQL?

Do you need to explicitly create an index, or is it implicit when defining the primary key? Is the answer the same for MyISAM and InnoDB?


Source: (StackOverflow)

How to get array keys in Javascript?

I have an array created with this code:

var widthRange = new Array();
widthRange[46] = { min:0,  max:52 };
widthRange[66] = { min:52, max:70 };
widthRange[90] = { min:70, max:94 };

I want to get each of the values 46, 66, 90 in a loop. I tried for (var key in widthRange) but this gives me a whole bunch of extra properties (I assume they are functions on the object). I can't use a regular for loop since the values are not sequential.


Source: (StackOverflow)

how do I make a composite key with SQL Server Management Studio?

how do I make a composite key with SQL Server Management Studio?

I want two INT columns to form the identity (unique) for a table


Source: (StackOverflow)

Surrogate vs. natural/business keys [closed]

Here we go again, the old argument still arises...

Would we better have a business key as a primary key, or would we rather have a surrogate id (i.e. an SQL Server identity) with a unique constraint on the business key field?

Please, provide examples or proof to support your theory.


Source: (StackOverflow)

How can I use the paid version of my app as a "key" to the free version?

Let's say for example that I have some Android app that does X. The free version has ads or basic features. I want to have a paid version that removes the ads and adds extra features.

How can I use the paid app as a "license key" to unlock the features in the free app?

So the user would install the free app, then install the paid app to get the extra features, but they would still run the free app (which would now be unlocked). What's the best approach to doing this?


Source: (StackOverflow)

How to get a random value in python dictionary

How can I get a random pair from a dict? I'm making a game where you need to guess a capital of a country and I need questions to appear randomly.

The dict looks like {'VENEZUELA':'CARACAS'}

How can I do this?


Source: (StackOverflow)

How can i tell if an object has a key value observer attached

if you tell an objective c object to removeObservers: for a key path and that key path has not been registered, it cracks the sads. like -

'Cannot remove an observer for the key path "theKeyPath" from because it is not registered as an observer.'

is there a way to determine if an object has a registered observer, so i can do this

if (object has observer){
  remove observer
}
else{
  go on my merry way
}

Source: (StackOverflow)

What is the difference between DSA and RSA?

It appears they are both encryption algorithms that require public and private keys. Why would I pick one versus the other to provide encryption in my client server application?


Source: (StackOverflow)

Java AES and using my own Key

I want to encrypt a string using AES with my own key. But I'm having trouble with the bit length of the key. Can you review my code and see what I need to fix/change.

public static void main(String[] args) throws Exception {
    String username = "bob@google.org";
    String password = "Password1";
    String secretID = "BlahBlahBlah";
    String SALT2 = "deliciously salty";

    // Get the Key
    byte[] key = (SALT2 + username + password).getBytes();
    System.out.println((SALT2 + username + password).getBytes().length);

    // Need to pad key for AES
    // TODO: Best way?

    // Generate the secret key specs.
    SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES");

    // Instantiate the cipher
    Cipher cipher = Cipher.getInstance("AES");
    cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec);

    byte[] encrypted = cipher.doFinal((secrectID).getBytes());
    System.out.println("encrypted string: " + asHex(encrypted));

    cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
    byte[] original = cipher.doFinal(encrypted);
    String originalString = new String(original);
    System.out.println("Original string: " + originalString + "\nOriginal string (Hex): " + asHex(original));
}

Right now I get an exception "Invalid AES key length: 86 bytes". Do I need to pad my key? How should I do it?

Also do I need to set anything for ECB or CBC?

Thanks


Source: (StackOverflow)

Google map signed api key errors in Android

When I switched from my debug map key to my signed map key my maps stop working. I get the following errors in logcat:

09-03 18:18:04.112: WARN/System.err(4073): IOException processing: 26
09-03 18:18:04.112: WARN/System.err(4073): java.io.IOException: Server returned: 3
09-03 18:18:04.112: WARN/System.err(4073):     at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115)
09-03 18:18:04.112: WARN/System.err(4073):     at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473)
09-03 18:18:04.112: WARN/System.err(4073):     at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:1117)
09-03 18:18:04.112: WARN/System.err(4073):     at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994)
09-03 18:18:04.112: WARN/System.err(4073):     at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702)
09-03 18:18:04.112: WARN/System.err(4073):     at java.lang.Thread.run(Thread.java:1019)

I've double checked everything, permissions and library are in place. I've recreated the singed key and no luck.

Any ideas?


Source: (StackOverflow)

How to elegantly rename all keys in a hash in Ruby? [duplicate]

This question already has an answer here:

I have a ruby hash:

ages = { "Bruce" => 32,
         "Clark" => 28
       }

Assuming I have another hash of replacement names, is there an elegant way to rename all the keys so that I end up with:

ages = { "Bruce Wayne" => 32,
         "Clark Kent" => 28
       }

Source: (StackOverflow)